<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<include file="Public:meta" />
</head>
<body id="main_page">
<include file="Public:position" />
<div class="container">
        <form enctype="multipart/form-data" method="post" id="frm">
        	<input type="hidden" name="p" id="p" value="{$NowPage}" />
            <div class="table">
               <div  class="toolbars">
                    <li class="toolbar"><a id="btnSaveAll" href="{$Url}Add"  title="添加广告内容" target="_self">添加广告内容</a></li>
                    <li class="toolbar"><a id="selectall" onclick="CheckAll()"  title="全选">全选</a></li>
                    <li class="toolbar"><a id="del" onclick="BatchDel()" title="批量删除">删除</a></li>
                    <li class="toolbar"><a id="sortall" onclick="BatchSort()" title="批量排序">排序</a></li>
                </div>
                <table class="datatable" id="datatable">
                    <tr>
                        <th width="30px"  nowrap="nowrap">选中</th>
                        <th width="45px" >广告ID</th>
                        <th width="145px" >广告名称</th>
                        <th width="65px" >广告排序</th>
                        <th width="70px" >广告类型</th>
                        <th width="115px" >所属广告位</th>
                        <th width="290px" >广告内容</th>
                        
                        <th>广告地址</th>
                        <th width="120px">发布时间</th>
                        <th width="60px">是否启用</th>
                        <th width="150px">操作</th>
                    </tr>
                    <notempty name="Data">  
                        <volist name="Data" id="d">
                            <tr id="tr{$d.AdID}">
                            <td><input class="checkrow" type="checkbox" name="id[]" value="{$d.AdID}" /></td>
                            <td>{$d.AdID}</td>
                            <td>{$d.AdName}</td>
                            <td>
                            <input type="text" class='textinput' onclick="this.select()" style="width:60px" name="OrderNumber[]" value="{$d.AdOrder}" />
                            <input type="hidden" class='textinput' name="OrderID[]" value="{$d.AdID}" />
                            </td>
                            <td>{$d.AdTypeName}</td>
                            <td style="font-weight:bold;color:blue;">{$d.AdGroupName}</td>
                            <td>
                                <switch name="d.AdTypeID">
                                    <case value="1"><img style="height:80px;max-width:275px; max-height:80px;" src='{$d.AdContent}' border='0' /></case>
                                    <case value="2|3">{$d.AdContent}</case>
                                    <default/>{$d.AdContent|htmlentities}
                                </switch>
                            </td>
                            <td><a href="{$d.AdUrl}" target="_blank">{$d.AdUrl}</a></td>
                            <td>{$d.AdTime|strtotime|yd_friend_date}</td>
                            <td>
                                <eq name="d.IsEnable" value="1">
                                    <span style="color:#000;cursor:pointer;"  onclick="toggleStatus(this,{$d.AdID},'ad')">启用</span>
                                <else/>
                                    <span style="color:#F00;cursor:pointer;"  onclick="toggleStatus(this,{$d.AdID},'ad')">禁用</span>
                                </eq>
                            </td>
                            <td class="operator">
                                <a style="float:left" id="btnEdit" name="btnEdit" href="{$Url}Modify/id/{$d.AdID}">修改</a>
                                <div class="btn-sep"></div>
                                <a style="float:left" onclick="Del({$d.AdID})" class="btnDel">删除</a>
                            </td>
                            </tr>
                        </volist>
                    <else/>
                        <tr><td colspan="11" id="NoData">{$Think.lang.NoDataTip}</td></tr>
                    </notempty>                                 
                </table>
                <div class="tfoot">
                    <div class="page"><span class="pagesize">每页<span class="pz">{$AdminPageSize}</span>条</span>{$Page}</div>
                </div>
            </div>
       </form>
</div>
</body>
</html>
<script type="text/javascript">
function Del(id){
	$.confirm("{$Think.lang.DeleteTip}", function () {
		url = "{$Url}del?id="+id+"&p={$NowPage}";
		location.href = url;
	}, function () {
		return true;
	});
}

//批量删除
function BatchDel(){
	//var arrChk = $("input[name='InfoID[]'][checked]"); //在高速浏览器长度总是返回0
	var arrChk = $("input[name='id[]']");
	var n = 0;
	for(var i = 0; i < arrChk.length; i++){
		if(arrChk[i].checked) n++;
	}
	
	if( n == 0 ) {
		WarnBox("{$Think.lang.CheckDeleteTip}");
		return;
	}
	
	$.confirm("{$Think.lang.DeleteTip}", function () {
		$('#frm').attr("action", "{$Url}del");
		$('#frm').submit();
	}, function () {
		return true;
	});
}

//排序
function BatchSort(){
	$.confirm("{$Think.lang.SortTip}", function () {
		$('#frm').attr("action", "{$Url}sort");
		$('#frm').submit();
	}, function () {
		return true;
	});
}
</script>